﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Space
{
    public class Weapon : Positioned
    {
        public float Damage { get; set; }

        public bool Alive { get; set; }

        public Ship Ship { get; set; }

        public virtual float Angle
        {
            get
            {
                return 0;
            }
        }

        public ITarget Target { get; set; }

        protected Game game;
        protected Game Game { get { return game; } }

        public Weapon(Ship ship)
        {
            Ship = ship;
            this.game = ship.Game;
        }
        public virtual void Update(float time)
        {
        }

        public virtual void DamageTarget(ITarget target)
        {
            if (target.HP <= 0)
            {
                if (Ship is FlagShip)
                {
                    FlagShip s = Ship as FlagShip;
                    s.Experience += target.Value;
                }
                else
                {
                    Ship.Player.FlagShip.Experience += target.Value / 10;
                }
            }
        }

        public virtual void Draw()
        {
            ICamera camera = Game.Services.GetService<ICamera>();
            Game.Content.Load<Model>("models/missile").Draw(Matrix.CreateRotationY(Angle) * Matrix.CreateTranslation(Position), camera.View, camera.Projection);
        }
    }
}
